package com.neusoft.demo10;

import java.util.*;

public class ListMapDemo {
    public static void main(String[] args) {
        List<Map<String,Employee>> list = new ArrayList();
        Map<String,Employee> map1 = new HashMap();
        Employee emp1 = new Employee();
        emp1.setName("fender");
        Employee emp2 = new Employee();
        emp2.setName("gibson");
        map1.put("1",emp1); //将员工添加到Map集合中
        map1.put("2",emp2);
        Map<String,Employee> map2 = new HashMap();
        Employee emp3 = new Employee();
        emp3.setName("fender3");
        Employee emp4 = new Employee();
        emp4.setName("gibson4");
        map2.put("3",emp3); //将员工添加到Map集合中
        map2.put("4",emp4);
        Map<String,Employee> map3 = new HashMap();
        Employee emp5 = new Employee();
        emp5.setName("fender5");
        Employee emp6 = new Employee();
        emp6.setName("gibson6");
        map3.put("5",emp5); //将员工添加到Map集合中
        map3.put("6",emp6);
        list.add(map1);
        list.add(map2);
        list.add(map3);

        //遍历集合
        Iterator<Map<String,Employee>> iterator = list.iterator();
        while (iterator.hasNext()) {
            Map<String,Employee> map = iterator.next();
            //对Map集合遍历
            Set<Map.Entry<String,Employee>> set = map.entrySet();
            Iterator<Map.Entry<String,Employee>> it = set.iterator();
            while (it.hasNext()) {
                Map.Entry<String,Employee> entry = it.next();
                Employee emp = entry.getValue();
                System.out.println(emp.getName());
            }
        }
    }
}
